package com.by.facade.enums.clue;

import com.by.facade.dto.clue.ClueWorkbenchConditionConvertAfterWDTO;
import com.by.facade.dto.clue.UserClueWorkbenchConditionWDTO;
import com.by.toolkit.enums.FlagEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2024/4/3 4:20 PM
 */
@Getter
@AllArgsConstructor
public enum SaleAfterStatusEnum {


    UN_PAY(SaleAfterStatusEnum.UN_PAY_CODE, "未支付", after -> after.setTradeStatus(TradeStatusEsEnum.UN_PAY_CODE), obj -> obj.setTradeStatus(TradeStatusEsEnum.UN_PAY_CODE)),
    PARTY_PAY(SaleAfterStatusEnum.PARTY_PAY_CODE, "部分支付", after -> after.setTradeStatus(TradeStatusEsEnum.PARTY_PAY_CODE), obj -> obj.setTradeStatus(TradeStatusEsEnum.PARTY_PAY_CODE)),
    COMPLETE_ORDER(SaleAfterStatusEnum.COMPLETE_ORDER_CODE, "成单", after -> after.setTradeStatus(TradeStatusEsEnum.COMPLETE_ORDER_CODE), obj -> obj.setTradeStatus(TradeStatusEsEnum.COMPLETE_ORDER_CODE)),
    REFUND(SaleAfterStatusEnum.REFUND_CODE, "退款", after -> after.setNextStageHaveRefundFlag(FlagEnum.YES.getCode()), obj -> obj.setNextStageHaveRefundFlag(FlagEnum.YES.getCode())),
    ;
    private final Integer status;

    private final String desc;

    private final Consumer<ClueWorkbenchConditionConvertAfterWDTO> consumer;

    private final Consumer<UserClueWorkbenchConditionWDTO> consumer2;

    public static final Map<Integer, SaleAfterStatusEnum> MAP;

    static {
        MAP = Stream.of(SaleAfterStatusEnum.values()).collect(Collectors.toMap(SaleAfterStatusEnum::getStatus, Function.identity()));
    }

    public static SaleAfterStatusEnum resolveByStatus(Integer status) {
        return MAP.get(status);
    }

    public static final int UN_PAY_CODE = 1;
    public static final int PARTY_PAY_CODE = 2;
    public static final int COMPLETE_ORDER_CODE = 3;
    public static final int REFUND_CODE = 4;


}
